/**
 * @Author : JiGuangJie
 * @Date : 2022/2/15
 * @Time : 16:58
 * @Version : 1.0.0
 * @descr :
 */
import babel from '@rollup/plugin-babel';
import {terser} from 'rollup-plugin-terser';
import typescript2 from 'rollup-plugin-typescript2';
import rollupConfigBase from './rollup.config.base';
import babelConfig from './babel.config';
import {version} from '../package.json';

const defaults = {
    compilerOptions: {
        declaration: true,
        declarationDir: `${process.cwd()}/dist/types`
    }
};

const extensions = [
    '.js', '.jsx', '.es6', '.es', '.mjs', '.ts'
];

export default {
    input: 'src/index.ts',    // 打包文件入口
    ...rollupConfigBase,
    output: {    // 输出文件配置
        dir: `./dist/`,
        format: 'umd',
        name: 'scmap',
        sourcemap: true,
        globals: {
            jquery: '$',
            ol: 'ol'
        },
        banner: ` /** @license scmap.version = '${version}' */`
    },
    plugins: [
        ...rollupConfigBase.plugins,
        typescript2({
            tsconfigDefaults: defaults,
            useTsconfigDeclarationDir: true
        }),
        babel({
            ...babelConfig,
            extensions
        })
        // terser()
    ],
    external: [
        'jquery',
        'ol'
    ]
};